package com.goldapp.calculator;

public class Convertion {

	double valor = 0;

	public Convertion() {

	}

	public Convertion(double valor) {
		super();
		this.valor = valor;
	}

	public void coordenada(int c1, int c2) {
		if (c1 == 0) {
			Peso(c2);
		} else if (c1 == 1) {
			Distancia(c2);
		} else {
			Volumen(c2);
		}

	}

	public double[] Peso(int c2) {
		double kg = 0, gr = 0, onza = 0, libra = 0, tone = 0;

		if (c2 == 0) {
			kg = valor * 1;
			gr = valor * 1000;
			onza = valor * 35.2739619;
			libra = valor * 2.20462262;
			tone = valor * 0.001;
		}
		if (c2 == 1) {
			kg = valor * 0.001;
			gr = valor * 1;
			onza = valor * 0.0352;
			libra = valor * 0.00220;
			tone = valor * 1.0E10 - 6;
		}
		if (c2 == 2) {
			kg = valor * 0.0283495231;
			gr = valor * 28.3495231;
			onza = valor * 1;
			libra = valor * 0.0625;
			tone = valor * 2.83495231E10 - 5;
		}
		if (c2 == 3) {
			kg = valor * 0.45359;
			gr = valor * 453.59237;
			onza = valor * 16;
			libra = valor * 1;
			tone = valor * 0.00045359237;
		}

		if (c2 == 4) {
			kg = valor * 1000;
			gr = valor * 1000000;
			onza = valor * 35273.9619;
			libra = valor * 2204.62262;
			tone = valor * 1;

		}
		return new double[] { kg, gr, onza, libra, tone };
	}

	public double[] Distancia(int c2) {
		double km = 0, yarda = 0, pul = 0, milla = 0, pie = 0, braza = 0, metros = 0;

		if (c2 == 0) {

			km = valor * 1;
			yarda = valor * 1093.6133;
			pul = valor * 39370.0787;
			milla = valor * 0.6213;
			pie = valor * 3280.8399;
			braza = valor * 546.8066;
			metros = valor * 1000;
		}
		if (c2 == 1) {
			km = valor * 0.0009144;
			yarda = valor * 1;
			pul = valor * 36;
			milla = valor * 0.0005681818;
			pie = valor * 3;
			braza = valor * 0.5;
			metros = valor * 0.9144;

		}

		if (c2 == 2) {
			km = valor * 2.54E-5;
			yarda = valor * 0.0277777;
			pul = valor * 1;
			milla = valor * 1.57828283E-5;
			pie = valor * 0.083333;
			braza = valor * 0.0138888888;
			metros = valor * 0.0254;

		}

		if (c2 == 3) {
			km = valor * 1.609344;
			yarda = valor * 1760;
			pul = valor * 63360;
			milla = valor * 1;
			pie = valor * 63360;
			braza = valor * 880;
			metros = valor * 1609.344;
		}

		if (c2 == 4) {
			km = valor * 0.0003048;
			yarda = valor * 0.33333;
			pul = valor * 12;
			milla = valor * 0.000189393;
			pie = valor * 1;
			braza = valor * 0.166666666;
			metros = valor * 0.3048;
		}
		if (c2 == 5) {
			km = valor * 0.0018288;
			yarda = valor * 2;
			pul = valor * 72;
			milla = valor * 1.00000000000000000000000000000;
			pie = valor * 6;
			braza = valor * 1;
			metros = valor * 1.8288;
		}

		if (c2 == 6) {

			km = valor * 0.001;
			yarda = valor * 1.0936133;
			pul = valor * 39.3700787;
			milla = valor * 0.000621371;
			pie = valor * 3.2808399;
			braza = valor * 0.546806649;
			metros = valor * 1;
		}

		return new double[] { km, yarda, pul, milla, pie, braza, metros };
	}

	public double[] Volumen(int c2) {
		double cm3 = 0, onza = 0, litro = 0, galon = 0, barril = 0, decil = 0, 
				decim3 = 0, metro3 = 0, ml = 0, y3 = 0;

		if (c2 == 0) {

			cm3 = valor * 1;
			onza = valor * 0.033814022701843;
			litro = valor * 0.001;
			galon = valor * 0.0002641720523;
			barril = valor * 6.284835E-6;
			decil = valor * 0.01;
			decim3 = valor * 0.001;
			metro3 = valor * 1.0E-6;
			ml = valor * 1;
			y3 = valor * 1.30796772E-6;
		}

		if (c2 == 1) {

			cm3 = valor * 29.573529;
			onza = valor * 1;
			litro = valor * 0.0295735295;
			galon = valor * 0.0078125;
			barril = valor * 6.284835E-6;
			decil = valor * 0.00018586476182546;
			decim3 = valor * 0.0295735295625;
			metro3 = valor * 2.95735295625E-5;
			ml = valor * 29.5735295625;
			y3 = valor * 3.868122223706e-5;
		}

		if (c2 == 2) {

			cm3 = valor * 1000;
			onza = valor * 33.8140227018;
			litro = valor * 1;
			galon = valor * 0.26417205235815;
			barril = valor * 0.006284835275;
			decil = valor * 10;
			decim3 = valor * 1;
			metro3 = valor * 0.001;
			ml = valor * 1000;
			y3 = valor * 0.00130796772;
		}

		if (c2 == 3) {

			cm3 = valor * 3785.411784;
			onza = valor * 128;
			litro = valor * 3.785411784;
			galon = valor * 1;
			barril = valor * 0.02379068951;
			decil = valor * 37.85411784;
			decim3 = valor * 3.785411784;
			metro3 = valor * 0.003785411784;
			ml = valor * 3785.411784;
			y3 = valor * 0.0049511964463;
		}

		if (c2 == 4) {

			cm3 = valor * 159113.15986982;
			onza = valor * 5380.256;
			litro = valor * 159.1131598698;
			galon = valor * 42.03325;
			barril = valor * 1;
			decil = valor * 1591.1315986;
			decim3 = valor * 159.113159869;
			metro3 = valor * 0.159113159869;
			ml = valor * 159113.15986982;
			y3 = valor * 0.20811487802;
		}

		if (c2 == 5) {

			cm3 = valor * 100;
			onza = valor * 3.3814022701;
			litro = valor * 0.1;
			galon = valor * 0.026417205235;
			barril = valor * 0.00062848352758387;
			decil = valor * 1;
			decim3 = valor * 0.1;
			metro3 = valor * 0.0001;
			ml = valor * 100;
			y3 = valor * 0.0001307967726859;
		}

		if (c2 == 6) {

			cm3 = valor * 1000;
			onza = valor * 33.814022701843;
			litro = valor * 1;
			galon = valor * 0.26417205235815;
			barril = valor * 0.0062848352758387;
			decil = valor * 10;
			decim3 = valor * 1;
			metro3 = valor * 0.001;
			ml = valor * 1000;
			y3 = valor * 0.001307967726859;
		}

		if (c2 == 7) {

			cm3 = valor * 1000000;
			onza = valor * 33814.022701843;
			litro = valor * 1000;
			galon = valor * 264.17205235;
			barril = valor * 6.2848352758;
			decil = valor * 10000;
			decim3 = valor * 1000;
			metro3 = valor * 1;
			ml = valor * 1000000;
			y3 = valor * 1.307967726;
		}

		if (c2 == 8) {

			cm3 = valor * 1;
			onza = valor * 0.03381402270;
			litro = valor * 0.001;
			galon = valor * 0.0002641720523581;
			barril = valor * 6.28483527583e-6;
			decil = valor * 0.01;
			decim3 = valor * 0.001;
			metro3 = valor * 1.0e-6;
			ml = valor * 1;
			y3 = valor * 1.3079677268e-6;
		}

		if (c2 == 9) {

			cm3 = valor * 764544.858;
			onza = valor * 25852.337184989;
			litro = valor * 764.544858;
			galon = valor * 0.0002641720523581;
			barril = valor * 201.9713842577;
			decil = valor * 7645.44858;
			decim3 = valor * 764.544858;
			metro3 = valor * 0.764544858;
			ml = valor * 764544.858;
			y3 = valor * 1;
		}

		return new double[] { cm3, onza, litro, galon, barril, decil, decim3,
				metro3, ml, y3 };
	}

	public double[] temperatura(int c2) {
		double cel = 0, fah = 0, newton = 0, kelvin = 0, rankine = 0, deslisle = 0;

		if (c2 == 0) { // celsius
			cel = valor * 1;
			fah = valor * 33.8;
			newton = valor * 0.33;
			kelvin = valor * 274.15;
			rankine = valor * 493.47;
			deslisle = valor * 148.5;

		}

		if (c2 == 1) { // Fahrenheit
			cel = valor * -17.222222222222;
			fah = valor * 1;
			newton = valor * -5.683333333333;
			kelvin = valor * 255.9277777777;
			rankine = valor * 460.67;
			deslisle = valor * 175.83333333;

		}

		if (c2 == 2) { // NewTon
			cel = valor * 3.030303030303;
			fah = valor * 37.45454545454;
			newton = valor * 1;
			kelvin = valor * 276.1803030303;
			rankine = valor * 497.1245454545;
			deslisle = valor * 145.4545454;

		}

		if (c2 == 3) { // Kelvin
			cel = valor * -272.15;
			fah = valor * -457.87;
			newton = valor * -89.8095;
			kelvin = valor * 1;
			rankine = valor * 1.8;
			deslisle = valor * 558.225;

		}

		if (c2 == 4) { // Rankine
			cel = valor * -272.59444444444;
			fah = valor * -458.67;
			newton = valor * -89.9561666666;
			kelvin = valor * 0.5555555555555;
			rankine = valor * 1;
			deslisle = valor * 558.891666666;

		}

		if (c2 == 5) { // Delisle
			cel = valor * 91;
			fah = valor * 195.8;
			newton = valor * 30.03;
			kelvin = valor * 364.15;
			rankine = valor * 655.47;
			deslisle = valor * 1;

		}

		return new double[] { cel, fah, newton, kelvin, rankine, deslisle };
	}
	
	
	public double[] area(int c2){
		double cm2 = 0, m2 = 0,ha = 0,km2 = 0,in2 = 0, ft2 = 0, yd2 = 0,acre = 0;
		
		if (c2 == 0) { // CM2
			cm2 = valor * 1;
			m2 = valor * 0.0001;
			ha = valor * 1.0E-8;
			km2 = valor * 1.0E-10;
			in2 = valor * 0.155;
			ft2 = valor * 0.001076;
			yd2 = valor * 0.00012;
			acre = valor * 2.4711E-8;

		}
		
		if (c2 == 1) { // M2
			cm2 = valor * 10000;
			m2 = valor * 1;
			ha = valor * 0.0001;
			km2 = valor * 0.000001;
			in2 = valor * 1550.0031;
			ft2 = valor * 10.76391;
			yd2 = valor * 1.19599;
			acre = valor * 0.000247;

		}
		
		if (c2 == 2) { // HA
			cm2 = valor * 100000000;
			m2 = valor * 10000;
			ha = valor * 1;
			km2 = valor * 0.01;
			in2 = valor * 15500031;
			ft2 = valor * 107639.104;
			yd2 = valor * 111959.9005;
			acre = valor * 2.471054;

		}
		
		if (c2 == 3) { // KM2
			cm2 = valor * 1.0000e-10;
			m2 = valor * 1000000;
			ha = valor * 100;
			km2 = valor * 1;
			in2 = valor * 1550003100;
			ft2 = valor * 10763910.4;
			yd2 = valor * 1195990.05;
			acre = valor * 1247.105381;

		}
		
		if (c2 == 4) { // IN2
			cm2 = valor * 6.4516;
			m2 = valor * 0.000645;
			ha = valor * 6.4516e-8;
			km2 = valor * 6.4516e-10;
			in2 = valor * 1;
			ft2 = valor * 0.006944;
			yd2 = valor * 0.000772;
			acre = valor * 1.5942e-7;

		}
		
		if (c2 == 5) { // FT2
			cm2 = valor * 929.0304;
			m2 = valor * 0.092903;
			ha = valor * 0.000009;
			km2 = valor * 9.2903E-8;
			in2 = valor * 144;
			ft2 = valor * 1;
			yd2 = valor * 0.111111;
			acre = valor * 0.000023;

		}
		
		if (c2 == 6) { // YD2
			cm2 = valor * 8361.2736;
			m2 = valor * 0.836127;
			ha = valor * 0.000084;
			km2 = valor * 8.3613E-7;
			in2 = valor * 1296;
			ft2 = valor * 9;
			yd2 = valor * 1;
			acre = valor * 0.000207;

		}
		
		if (c2 == 7) { // ACRE
			cm2 = valor * 40468564.2;
			m2 = valor * 4046.85642;
			ha = valor * 0.404686;
			km2 = valor * 0.004047;
			in2 = valor * 6272.640;
			ft2 = valor * 43560;
			yd2 = valor * 4840;
			acre = valor * 1;

		}
		
		
		
		return new double[]{cm2, m2,ha,km2,in2, ft2, yd2, acre};
	}

	
	
	public double getValor() {

		return valor;
	}

	public void setValor(double valor) {
		this.valor = valor;
	}

}
